<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
	<link href="/static/component/layui/css/layui.css" rel="stylesheet" />
	<link href="/static/admin/css/pearCommon.css" rel="stylesheet" />
</head>
<body>
<body class="pear-container">
<div class="layui-card">
	<div class="layui-card-body">
		<form class="layui-form" action="">
			<div class="layui-form-item">
				<label class="layui-form-label">文章名称</label>
				<div class="layui-input-inline">
					<input type="text" name="realName" placeholder="" class="layui-input">
				</div>
				<label class="layui-form-label">分类</label>
				<div class="layui-input-inline">
					<select name="classify" lay-verify="required" lay-filter="classify">
						<<< range .Classify >>>
						<option value="<<<.Id>>>"> <<<.Name>>> </option>
						<<< end >>>
					</select>
				</div>
				<label class="layui-form-label">日期</label>
				<div class="layui-input-inline">
					<input type="text" name="username" placeholder="" class="layui-input">
				</div>
				<div class="layui-form-mid">-</div>
				<div class="layui-input-inline">
					<input type="text" name="username" placeholder="" class="layui-input">
				</div>
				<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="user-query">
					<i class="layui-icon layui-icon-search"></i>
					查询
				</button>
				<button type="reset" class="pear-btn pear-btn-md">
					<i class="layui-icon layui-icon-refresh"></i>
					重置
				</button>
			</div>
		</form>
	</div>
</div>
<div class="layui-card">
	<div class="layui-card-body">
		<table id="user-table" lay-filter="user-table"></table>
	</div>
</div>
</body>

<script type="text/html" id="user-bar">
	<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i></button>
</script>

<script type="text/html" id="article-comment">
	<input type="checkbox" name="comment" value="{{d.Id}}" lay-skin="switch" lay-text="是|否" lay-filter="user-enable" checked = "{{ d.Comment == 0 ? 'true' : 'false' }}">
</script>

<script type="text/html" id="article-top">
	<input type="checkbox" name="top" value="{{d.Id}}" lay-skin="switch" lay-text="是|否" lay-filter="user-enable" checked = "{{ d.Top == 0 ? 'true' : 'false' }}">
</script>


<script type="text/html" id="user-createTime">
	{{layui.util.toDateString(d.CreateAt, 'yyyy-MM-dd')}}
</script>

<script src="/static/component/layui/layui.js"></script>
<script>
	layui.use(['table','form','jquery'],function () {
		let table = layui.table;
		let form = layui.form;
		let $ = layui.jquery;

		let cols = [
			[
				{type:'checkbox'},
				{title: '键', field: 'key', width:250},
				{title: '值', field: 'value', width:300},
				{title: '描述', field: 'Desc'},
				{title: '操作', toolbar: '#user-bar', align:'center', width:130}
			]
		];

		table.render({
			elem: '#user-table',
			url: '/api/admin/config/query',
			page: true ,
			cols: cols ,
			skin: 'line',
			contentType: 'application/json',
			method: "post",
			toolbar: true,
			defaultToolbar: [{
				layEvent: 'refresh',
				icon: 'layui-icon-refresh',
			}, 'filter', 'print', 'exports']
		});

		table.on('tool(user-table)', function(obj){
			if(obj.event === 'edit'){
				window.edit(obj);
			}
		});

		table.on('toolbar(user-table)', function(obj){
			if(obj.event === 'refresh'){
				window.refresh();
			}
		});

		window.edit = function(obj){
			layer.open({
				type: 2,
				title: '修改',
				shade: 0.1,
				area: ['400px', '300px'],
				content: '/admin/config/edit/'+obj.data.id
			});
		};


		window.refresh = function(param){
			table.reload('user-table');
		}
	})
</script>
</body>
</html>
